package stringexample;

/**
 * @License: (C) Copyright 2013-2022
 * @Contact: abcque@outlook.com
 * @IDE: IntelliJ IDEA
 * @Encoding: utf-8
 * @Project: st2214st2215
 * @Package: stringexample
 * @File: StringFunc.java
 * @Time: 2023/4/4 14:15
 * @Author: abcque
 * @Description:
 * @Modifier:
 * @ModifyDate:
 * @ModifyRemark:
 */
public class StringFunc {
    public static void main(String[] args) {
        String str = "Hello, World";

        int length = str.length();
        System.out.println("length = " + length);

        char c = str.charAt(0);
        System.out.println("c = " + c);

        boolean empty = str.isEmpty();
        System.out.println("empty = " + empty);

        String lowerCase = str.toLowerCase();
        System.out.println("lowerCase = " + lowerCase);

        String upperCase = str.toUpperCase();
        System.out.println("upperCase = " + upperCase);

        String s = "    Hello, World  ";
        String trim = s.trim();
        System.out.println("trim = " + trim);

        boolean equals = str.equals(trim);
        System.out.println("equals = " + equals);

        boolean ignoreCase = lowerCase.equalsIgnoreCase(upperCase);
        System.out.println("ignoreCase = " + ignoreCase);

        String concat = str.concat(s);
        System.out.println("concat = " + concat);

        int compare = s.compareTo(str);
        System.out.println("compare = " + compare);

        String s1 = str.substring(4);
        System.out.println("s1 = " + s1);
        String s2 = str.substring(4, 6);
        System.out.println("s2 = " + s2);

        boolean endsWith = str.endsWith("d");
        System.out.println("endsWith = " + endsWith);

        boolean startsWith = str.startsWith("He");
        System.out.println("startsWith = " + startsWith);

        boolean starts = str.startsWith("e", 1);
        System.out.println("starts = " + starts);

        boolean contains = str.contains("ll");
        System.out.println("contains = " + contains);

        int index1 = str.indexOf("l");
        System.out.println("index1 = " + index1);

        int index2 = str.lastIndexOf("l");
        System.out.println("index2 = " + index2);


    }
}
